#pragma once
#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QImage>
#include <QWaitCondition>

#include "MessageHelper.h"

class SendImgThread : public QThread {
    Q_OBJECT
public:
    static const int QUEUE_MAXSIZE = 1500;
    static const int WAITSECONDS= 2;

    SendImgThread(QObject *parent = nullptr) : QThread(parent) {}
    
    void pushToQueue(QImage);
public slots:
    void ImageCapture(QImage); //捕获到视频帧
    void clearImgQueue(); //线程结束时，清空视频帧队列
    void stopImmediately();

private:
    MsgQueue imgqueue;
    QMutex queue_lock;
    QWaitCondition queue_waitCond;
    void run() override;
    QMutex m_lock;
    volatile bool m_isCanRun;
};